#!/sbin/openrc-run
supervisor="supervise-daemon"

: ${command_user:=turn-rs:turn-rs}
: ${logdir=/var/log/turn-rs}
: ${_conf_path=/etc/turn-rs/turn-server.toml}

name=turn-server
description="Pure Rust turn server implementation"
command="/usr/bin/turn-server"
command_args="--config $_conf_path"
command_background=true

pidfile="/run/$RC_SVCNAME.pid"
output_log="$logdir/output.log"
error_log="$logdir/error.log"

depend() {
	need net
}

start_pre() {
	checkpath -f -m 0644 -o "$command_user" "$output_log" "$error_log"
	checkpath -f -m 0600 -o "$command_user" "$_conf_path"
}
